package com.dot.base.wait01;

public class Test01 {
    private Object objectLock = new Object();
    public static void main(String[] args) throws InterruptedException {
        new Test01().print();
        new Test01().print();
    }
    public void print() throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (objectLock){
                    System.out.println(">1<");
                    try {
                        objectLock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(">2<");
                }
            }
        }).start();
        try {
            Thread.sleep(3000);
            synchronized (objectLock){
                objectLock.notify();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
